package com.angel.core.util;

import java.util.Calendar;

import com.angel.core.Constants;

/**
 * @author hanlinxiu
 *
 */
public class CodeUtil {
	
	/**
	 * 编码规则 省 市 年份 业务 id
	 * 
	 * @param areaCode 区域编码
	 * @param serviceCode 服务编码
	 * @param id id
	 * @return
	 */
	public static String createCode(String areaCode, String serviceCode, Integer id){

		String yearCode = "";
		String idCode = "000000";
		String idStr = "";
		
		Calendar calendar = Calendar.getInstance();
		int year = calendar.get(Calendar.YEAR);
		yearCode = String.valueOf(year).substring(2);
		
		if(id != null)
			idStr = String.valueOf(id);
		
		idCode = idCode.substring(0, idCode.length()-idStr.length()) + idStr;
		
		return (StringUtils.isEmpty(areaCode)?"000000":areaCode) + yearCode + serviceCode + idCode;
	} 
	
}
